import request from "@/utils/request";

// 获取详情列表
export function TemsCourseCatalog(data) {
  return request({
    url: `/api/course/TemsCourseCatalog/Selector`,
    method: "get",
    data: data,
  });
}
// 获取课程列表
export function TemsCourseList(data) {
  return request({
    url: `/api/course/TemsCourse/getStudyList`,
    method: "POST",
    data: data,
  });
}

//

export function TemsCourseDetail(id) {
  return request({
    url: `/api/course/TemsCourse/detail/${id}`,
    method: "GET",
  });
}

/**
 * 课程学习
 * @param chapterId
 * @param process
 * @returns {*}
 * @constructor
 */
export function TemsCourseStudy(chapterId, process) {
  return request({
    url: `/api/course/TemsCourse/study/${chapterId}`,
    method: "POST",
    data: { process: process || 0 },
  });
}

/**
 * 课程评分
 * @param studyId
 * @param starScore
 * @returns {*}
 * @constructor
 */
export function TemsCourseStar(studyId, starScore) {
  return request({
    url: `/api/course/TemsCourse/star/${studyId}`,
    method: "POST",
    data: { starScore: starScore || 0 },
  });
}

/**
 * 收藏/点赞
 * @param type 收藏/点赞
 * @param id 课程ID
 * @returns {*}
 * @constructor
 */
export function TemsCourseFavorite(type, id, name, cover) {
  return request({
    url: "/api/course/TemsFavoriteUser",
    method: "POST",
    data: { type: type, resourceType: "course", resourceId: id, name, cover },
  });
}
